<include file="Public:header"/>
<style>
input{padding:6px;}
.title{background:#E2E8EB;width:100px;text-align:right;}
.tpl{background:#E2E8EB;width:120px;text-align:center;}
</style>

<input type="button" id="sys" value="邮件系统配置" style="padding:2px">
<table border="0" width="300px" cellspacing="3" cellpadding="3">
	<tr>
		<td class="title">注册成功时：</td>
		<td>
		<select name="reg">
<if condition="$reg eq '1'">
		    <option value="0">关闭</option>
		    <option value="1" selected>开启</option>
<else/>
			<option value="0" selected>关闭</option>
		    <option value="1">开启</option>
</if>
		</select>
		</td>
		<td class="tpl"><a href="javascript:;" onclick="settpl('reg')">内容模板</a></td>
	</tr>
	<tr>
		<td class="title">提交订单时：</td>
		<td>
		<select name="order">
<if condition="$order eq '1'">
		    <option value="0">关闭</option>
		    <option value="1" selected>开启</option>
<else/>
			<option value="0" selected>关闭</option>
		    <option value="1">开启</option>
</if>
		</select>
        </td>
		<td class="tpl"><a href="javascript:;" onclick="settpl('order')">内容模板</a></td>
	</tr>
	<tr>
		<td class="title">支付完成时：</td>
		<td>
		<select name="pay">
<if condition="$pay eq '1'">
		    <option value="0">关闭</option>
		    <option value="1" selected>开启</option>
<else/>
			<option value="0" selected>关闭</option>
		    <option value="1">开启</option>
</if>
		</select>
		</td>
		<td class="tpl"><a href="javascript:;" onclick="settpl('pay')">内容模板</a></td>
	</tr>
	<tr>
		<td class="title">订单发货时：</td>
		<td>
			<select name="ship">
<if condition="$ship eq '1'">
		    <option value="0">关闭</option>
		    <option value="1" selected>开启</option>
<else/>
			<option value="0" selected>关闭</option>
		    <option value="1">开启</option>
</if>
		</select>
		</td>
		<td class="tpl"><a href="javascript:;" onclick="settpl('ship')">内容模板</a></td>
	</tr>

</table>


<div id="save"><input type="button" id="change" value="保存修改" style="padding:2px"></div>

<script src="__APP__/statics/webox/webox.js"></script>
<link href="__APP__/statics/webox/jquery-webox.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
$("#sys").click(function(){
		$.webox({
		    scroll:'no',
			height:350,
			width:800,
			bgvisibel:true,
			title:'邮件系统配置',
			iframe:'__URL__/email_sys/'+Math.random
		});
})

function settpl(t){
   var type=t;
	$.webox({
		height:450,
		width:1000,
		bgvisibel:true,
		title:'邮件内容模板',
		iframe:'__URL__/email_tpl/?type='+type
	});
}

$("#change").click(function(){
   var reg=$("[name=reg]").val();
   var order=$("[name=order]").val();
   var pay=$("[name=pay]").val();
   var ship=$("[name=ship]").val();
   
   $.ajax({
        type:"POST",
		url:"__URL__/email/?action=save",
		dataType:"json",
		data:{"reg":reg,"order":order,"pay":pay,"ship":ship},
		success:function(data){
		    jSuccess("<strong>修改成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
       }
   })
})
</script>
